﻿using Models;
using System.Diagnostics;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using ViewModels;

namespace WorkPieceDataCapture.Views
{
    /// <summary>
    /// uc_ProduceDetail.xaml 的交互逻辑
    /// </summary>
    public partial class uc_ProduceDetail : UserControl
    {
        public uc_ProduceDetail(tb_WorkPieceDataCapture_Realtime model)
        {
            InitializeComponent();
            this.DataContext = new vm_ProduceDetail(model);
        }

        private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            var btn = sender as Button;
            if (btn.Content == null || btn.Content.ToString() == "") return;
            var vm = this.DataContext as vm_ProduceDetail;
            switch (btn.Tag.ToString())
            {
                case "path":    //根据显示的路径打开文件
                    var result = GlobalClass.openFile(btn.Content.ToString());
                    if (!result.bSuccess)
                    {
                        MessageBox.Show(result.strMsg);
                    }
                    break;
                case "ylqxt_search":    //压力曲线图
                    if (vm != null && vm.PressureCurve.CanExecute(null)) vm.PressureCurve.Execute("Search");
                    break;
                default:
                    break;
            }


        }
    }
}
